//**********************************************
//
//**********************************************


#ifndef TINKLE_INCLUDE_XMLNODE_H
#define TINKLE_INCLUDE_XMLNODE_H

#include <memory>
#include <string>
#include <libxml/tree.h>
namespace tinkle{
	class XmlElement;

	typedef std::auto_ptr<XmlElement> ElementPtr;

	class XmlElement {
	public:
		XmlElement() {}
		XmlElement(const XmlElement &a) {}

		virtual bool IsNull() const {return true;};
		//  get and change element name
		virtual std::string GetName() const {return "";};
		virtual void SetName(const std::string& name) {};
		
		//  declare a namespace on this element, if want to declare a
		//default namespace, make prefix = ""
		virtual void DeclNameSpace(const std::string &href, const std::string &prefix) {};

		//  set namespace through a prefix, if the prefix didn't exist
		//it' ll create one
		virtual void SetNameSpace(const std::string &prefix) {};

		//  get the declaration of a default namespace, get default namespace declaration with a ""
		//if not found, return ""
		//note: For a XMPP node, it may be possible that current node didn't contain the declaration of
		//      its prefixed namespace
		virtual std::string GetNsDecl(const std::string &prefix) const {return "";};		

		//  get the prefix name on this element.
		virtual std::string GetPrefix() const {return "";};

		//  set and get attribute value, don't use namespace as a parameter, they are incomplete
		virtual void SetAttrValue(const std::string &name, const std::string &value, const std::string &ns = "") {};
		virtual std::string GetAttrValue(const std::string &name, const std::string &ns = "") {return NULL;};

		virtual ElementPtr AddChild(const std::string &name) {return ElementPtr();};
		virtual ElementPtr GetChild(const std::string &name) {return ElementPtr();};

		virtual void SetContent(const std::string& name) {};
		virtual std::string GetContent() const {return "";};

	protected:
	private:
	};
	
	
	
	class XmlNode{
	public:   
	   std::string Dump() const;
	
	   ElementPtr operator() () const;
	   virtual ElementPtr GetElement() const;
	   //enable copying node	  
	   
	   explicit XmlNode(const std::string& name);
	   explicit XmlNode(const XmlNode& another);
	   XmlNode& operator =(const XmlNode& another);

	   ~XmlNode();

	protected:		
		xmlNodePtr _p;
	};
}


#endif